//
//  BaseViewController.swift
//  lixiangweibo
//
//  Created by dyy on 15/11/24.
//  Copyright © 2015年 lixianggongzuoshi. All rights reserved.
//

import UIKit
//遵守代理协议
class BaseViewController: UITableViewController,visitorLoginViewDelegate {

    //访客登录视图
    var visitorLoginView : VisitorLoginView?
    //用户登录标记
    var userLogin = false
    
    override func loadView() {
        //判断用户登录,如果登录了,就直接返回
        if userLogin{
        
        super.loadView()
            
            return
        }
        //替换视图
        visitorLoginView = NSBundle .mainBundle().loadNibNamed("VisitorLoginView", owner: nil, options: nil).last as? VisitorLoginView
        //设置代理
        visitorLoginView?.delegate = self
        
        view = visitorLoginView
        //设置导航栏按钮
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewRegisterViewDidSelected")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewLoginViewDidSelected")
        
        
    }
    //实现代理方法
    func visitorViewLoginViewDidSelected() {
       
        print("\(__FUNCTION__)")
        
    }
    func visitorViewRegisterViewDidSelected() {
        print("\(__FUNCTION__)")
        

    }
    
}
